package ${groupId}.controller.system.sysrole;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import ${groupId}.dal.mybatis.model.SysRole;
import ${groupId}.dal.mybatis.model.SysRoleResource;
import ${groupId}.service.system.sysrole.SysRoleService;
import ${groupId}.service.system.sysrole.dto.SysRoleAddItemReqDto;
import ${groupId}.service.system.sysrole.dto.SysRoleQueryFilter;
import ${groupId}.service.system.sysrole.dto.SysRoleUpdateItemReqDto;
import com.system.core.controller.ControllerBase;
import com.system.core.results.ResultBase;
import com.system.core.view.layui.table.TableViewRspDto;

import io.swagger.v3.oas.annotations.Hidden;

@Controller
@RequestMapping("boss/sys_role")
@Hidden
public class SysRoleController extends ControllerBase {
	@Autowired
	private SysRoleService sysRoleService;
	
	@RequestMapping(value = "to_page",method = RequestMethod.GET)
	public String toPage() {
		return "/system/sysRole/sysRole-list";
	}
	
	@RequestMapping(value = "query_list",method = RequestMethod.POST)
	@ResponseBody
	public TableViewRspDto<SysRole> sysRoleQueryList(SysRoleQueryFilter filter) {
		TableViewRspDto<SysRole> rsp = sysRoleService.sysRoleList(filter);
		return rsp;
	}
	
	@RequestMapping(value = "get_by_pk",method = RequestMethod.POST)
	@ResponseBody
	public SysRole sysRoleGetByPrimaryKey(SysRole sysRole){
		return sysRoleService.sysRoleGetByPrimaryKey(sysRole);
	}
	
	@RequestMapping(value = "add_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysRoleAddItem(@Validated SysRoleAddItemReqDto sysRoleAddItemReqDto) {
		return sysRoleService.sysRoleSave(sysRoleAddItemReqDto);
	}
	
	@RequestMapping(value = "update_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysRoleUpdateItem(@Validated SysRoleUpdateItemReqDto sysRoleUpdateItemReqDto) {
		return sysRoleService.sysRoleUpdateByPrimaryKey(sysRoleUpdateItemReqDto);
	}
	
	@RequestMapping(value = "delete_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysRoleDeleteItem(@RequestBody List<Long> keys) {
		return sysRoleService.sysRoleDeleteByPrimaryKey(keys);
	}
	
	@RequestMapping(value = "getResourceByRoleId",method = RequestMethod.POST)
	@ResponseBody
	public List<Long> getResourceByRoleId(Long roleId) {
		return sysRoleService.getResrouceByRoleId(roleId);
	}
	
	@RequestMapping(value = "updateRoleResource",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase updateRoleResource(@RequestBody List<SysRoleResource> resourceIds) {
		return sysRoleService.updateRoleResource(resourceIds);
	}
}
